]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Example Assets/portraits/CustomPortrait_AnimatedSprite.gd
Initial Godot project with Dialogic 2.0-Alpha-17
[wolf-seeking-sheep.git] / addons / dialogic / Example Assets / portraits / CustomPortrait_AnimatedSprite.gd
1 @tool
2 extends DialogicPortrait
3
4 # If the custom portrait accepts a change, then accept it here
5 func _update_portrait(passed_character:DialogicCharacter, passed_portrait:String) -> void:
6         if passed_portrait == "":
7                 passed_portrait = passed_character['default_portrait']
8
9         if $Sprite.sprite_frames.has_animation(passed_portrait):
10                 $Sprite.play(passed_portrait)
11
12 func _on_animated_sprite_2d_animation_finished() -> void:
13         $Sprite.frame = randi()%$Sprite.sprite_frames.get_frame_count($Sprite.animation)
14         $Sprite.play()
15
16
17 func _get_covered_rect() -> Rect2:
18         return Rect2($Sprite.position, $Sprite.sprite_frames.get_frame_texture($Sprite.animation, 0).get_size()*$Sprite.scale)